---
displayed_sidebar: "Chinese"
keywords: ['suoyin']
---

# SHOW INDEX

## 功能

查看索引，当前仅支持查看指定表的所有 [Bitmap 索引](../../../table_design/indexes/Bitmap_index.md)。创建 bitmap 索引为异步过程，使用该语句只能查看到已经创建完成的索引。

:::tip

该操作不需要权限。

:::

## 语法

```SQL
SHOW INDEX[ES] FROM [db_name.]table_name [FROM db_name]
```

或

```SQL
SHOW KEY[S] FROM [db_name.]table_name [FROM db_name]
```

## 参数说明

| **参数**   | **必选** | **说明**     |
| ---------- | -------- | ------------ |
| db_name    | 否       | 数据库名称。 |
| table_name | 是       | 表名。       |

## 返回结果说明

```Plain
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table   | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
```

返回结果中的参数说明：

| **参数**    | **说明**         |
| ----------- | ---------------- |
| Key_name    | 索引名称。       |
| Column_name | 创建索引的列名。 |
| Index_type  | 索引类型。       |
| Comment     | 索引备注。       |

> 说明：当前仅支持查看 bitmap 索引，bitmap 索引的相关信息仅包括以上四个参数。返回结果中的其他参数和 bitmap 索引无关。

## 示例

为表`sales_records`中的`item_id`列创建 bitmap 索引，索引名称为`index3`。表`sales_records`所属数据库为`d0`。

```SQL
CREATE INDEX index3 ON sales_records (item_id) USING BITMAP COMMENT '';
```

查看表`sales_records`的所有索引。

```Plain
SHOW INDEX FROM d0.sales_records;

+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table                            | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| default_cluster:d0.sales_records |            | index3   |              | item_id     |           |             |          |        |      | BITMAP     | NULL    |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
```

或

```Plain
SHOW KEY FROM sales_records FROM d0;

+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table                            | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| default_cluster:d0.sales_records |            | index3   |              | item_id     |           |             |          |        |      | BITMAP     | NULL    |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
```
